package com.lovo.boot.controller;

import com.lovo.boot.entity.UserEntity;
import com.lovo.boot.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.catalina.User;
import org.apache.catalina.mbeans.UserMBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@Api(tags = "测试接口")
public class TestController {

    @Autowired
    private IUserService service;

//    @ApiOperation(value = "测试")
//    @GetMapping("test")
//    public UserEntity test(UserEntity userEntity){
//        return userEntity;
//    }

//    @ApiOperation(value = "查询用户")
//    @GetMapping("findUser")
//    public List<UserEntity> findUser(){
//        return  service.findUserAll();
//    }

//    @GetMapping("userInfo/{tag}/1/2")
//    public UserEntity userInfo(@PathVariable("tag") int tag){
//        UserEntity userEntity=new UserEntity();
//        if(tag==0) {
//            userEntity.setUserName("张三");
//        }else if(tag==1){
//            userEntity.setUserName("李四");
//        }
//        return userEntity;
//    }

    @ApiOperation(value = "按成绩查询用户")
    @GetMapping("findGrade")
    public List<UserEntity> findGrade(int startGrade,int endGrade){
        return service.findByGrade(startGrade,endGrade);
    }

    @ApiOperation(value = "删除并查询用户")
    @DeleteMapping("del")
    public List<UserEntity> del(@ApiParam(value = "精确姓名") String name){
        return service.del(name);
    }
}